import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CompanyVO, CompanyForm, CompanyQuery } from '@/api/company/types';

/**
 * 查询主体信息列表
 * @param query
 * @returns {*}
 */

export const listCompany = (query?: CompanyQuery): AxiosPromise<CompanyVO[]> => {
  return request({
    url: '/admin/company/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询主体信息详细
 * @param id
 */
export const getCompany = (id: string | number): AxiosPromise<CompanyVO> => {
  return request({
    url: '/admin/company/' + id,
    method: 'get'
  });
};

/**
 * 新增主体信息
 * @param data
 */
export const addCompany = (data: CompanyForm) => {
  return request({
    url: '/admin/company',
    method: 'post',
    data: data
  });
};

/**
 * 修改主体信息
 * @param data
 */
export const updateCompany = (data: CompanyForm) => {
  return request({
    url: '/admin/company',
    method: 'put',
    data: data
  });
};

/**
 * 删除主体信息
 * @param id
 */
export const delCompany = (id: string | number | Array<string | number>) => {
  return request({
    url: '/admin/company/' + id,
    method: 'delete'
  });
};

//登录用户查询有没有补全主体信息 
export const checkCompany = () => {
  return request({
    url: '/company/company/hasCompanyId',
    method: 'get'
  });
};

//补全公司信息
export const completeCompany = (data) => {
  return request({
    url: '/company/company',
    method: 'post',
    data: data
  });
};

export const completeCompany2 = (data) => {
  return request({
    url: '/company/company',
    method: 'put',
    data: data
  });
};


//获取主体详情
export const getCompanyDetail = () => {
  return request({
    url: '/company/employee/getInfoAndCompany',
    method: 'get'
  });
};

//获取主体地址列表
export const addAddress = (data) => {
  return request({
    url: '/company/address',
    method: 'post',
    data: data
  });
};
